<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ taglib uri="http://eureka.yigolden.net/stringutils/sutaglib/1.0" prefix="su"%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0, user-scalable=no">
<title>查询帖子</title>

  <!-- Bootstrap -->
    <link href="<%=request.getContextPath()%>/static/css/bootstrap.min.css" rel="stylesheet">
    <link href="<%=request.getContextPath()%>/static/css/bootstrap-theme.min.css" rel="stylesheet">
    <link href="<%=request.getContextPath()%>/static/css/jumbotron.css" rel="stylesheet">
    
    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
      <script src="<%=request.getContextPath()%>/static/js/html5shiv.min.js"></script>
      <script src="<%=request.getContextPath()%>/static/js/respond.min.js"></script>
    <![endif]-->
    
    
</head>
<body>
<jsp:include page="../Common/navHeader.jsp"></jsp:include>

<div class="container">

	  <br>
	  <br>       
     <jsp:include page="/Common/SearchArea.jsp"></jsp:include>
       
      <br/>
      <br/>   
      
	  <div class="row">
      <div class="col-sm-2"></div><!--左侧不用-->
      
      <div class="col-sm-8 col-xs-12">
	  
	  <c:set var="i" value="0" />
      <c:if test="${page ne null }">

      <c:if test="${page.countAll ne 0 }">
            
      <c:if test="${!empty param.domain }">
      	<a class="btn btn-success btn-md" href="<%=request.getContextPath() %>/Posting/AddPosting?domain=${fn:escapeXml(param.domain)}" role="button">发帖&raquo;</a>
      </c:if>
	  
	  <div class="table-responsive">
	    <table class="table table-hover table-stripped">
		  <tr style="background:aliceblue">
		    <td style="min-width:60px">类型</td>
		    <td>主题</td>
		    <td>发布者</td>
		    <td>发布时间</td>
		  </tr>
		  
		  <c:set var="i" value="0" />
		  <c:forEach var="item" items="${page.records}">
		    <c:set var="i" value="${i + 1 }" />
			<tr>
			  <td>[${fn:escapeXml(item.type) }]</td>
			  <td><a href="<%=request.getContextPath() %>/Posting/ShowPosting?postingid=${item.postingid }" target="_blank">${fn:escapeXml(item.topic) }</a></td>
			  <td>${fn:escapeXml(item.postmanname) }</td>
			  <td>${fn:escapeXml(item.timeFormatted) }</td>
			</tr>
		  </c:forEach>
		</table>
	  </div>
	   
	  <br/>
	 
	       <div class="row" style="text-align:center;">
      <nav> 
          <ul class="pagination">
            <c:choose>
		    <c:when test = "${page.hasPrevious}">
		    <li><a href="?keyword=${keywordEncoded }&postman=${postman }&domain=${DomainEncoded }&type=${TypeEncoded }&curPage=1&pageSize=${page.pageSize}"><span aria-hidden="true">&laquo;</span></a></li>
            <li><a href="?keyword=${keywordEncoded }&postman=${postman }&domain=${DomainEncoded }&type=${TypeEncoded }&curPage=${page.prePage}&pageSize=${page.pageSize}"><span aria-hidden="true">&lt;</span></a></li>
		    </c:when>
		    <c:otherwise>
		    <li class="disabled"><a href="#" onclick="return false;"><span aria-hidden="true">&laquo;</span></a></li>
		    </c:otherwise>
		    </c:choose>
		     
		    <c:if test="${page.currentPage-3 gt 0}">
            <li><a href = "?keyword=${keywordEncoded }&postman=${postman }&domain=${DomainEncoded }&type=${TypeEncoded }&curPage=${page.currentPage-3}&pageSize=${page.pageSize}">${page.currentPage-3}</a></li>
            </c:if>
            <c:if test="${page.currentPage-2 gt 0}">
            <li><a href = "?keyword=${keywordEncoded }&postman=${postman }&domain=${DomainEncoded }&type=${TypeEncoded }&curPage=${page.currentPage-2}&pageSize=${page.pageSize}">${page.currentPage-2}</a></li>
            </c:if>
            <c:if test="${page.currentPage-1 gt 0}">
            <li><a href = "?keyword=${keywordEncoded }&postman=${postman }&domain=${DomainEncoded }&type=${TypeEncoded }&curPage=${page.currentPage-1}&pageSize=${page.pageSize}">${page.currentPage-1}</a></li>
            </c:if>
            <li class="active"><a href="#">${page.currentPage}</a></li>
             
             <c:if test="${page.maxPage - page.currentPage -0 gt 0}">
            <li><a href = "?keyword=${keywordEncoded }&postman=${postman }&domain=${DomainEncoded }&type=${TypeEncoded }&curPage=${page.currentPage+1}&pageSize=${page.pageSize}">${page.currentPage+1}</a></li>
            </c:if>
            <c:if test="${page.maxPage - page.currentPage -1 gt 0}">
            <li><a href = "?keyword=${keywordEncoded }&postman=${postman }&domain=${DomainEncoded }&type=${TypeEncoded }&curPage=${page.currentPage+2}&pageSize=${page.pageSize}">${page.currentPage+2}</a></li>
            </c:if>
            <c:if test="${page.maxPage - page.currentPage -2 gt 0}">
            <li><a href = "?keyword=${keywordEncoded }&postman=${postman }&domain=${DomainEncoded }&type=${TypeEncoded }&curPage=${page.currentPage+3}&pageSize=${page.pageSize}">${page.currentPage+3}</a></li>
            </c:if>

            <c:choose>
		    <c:when test = "${page.hasNext}">
            <li><a href="?keyword=${keywordEncoded }&postman=${postman }&domain=${DomainEncoded }&type=${TypeEncoded }&curPage=${page.nextPage}&pageSize=${page.pageSize}"><span aria-hidden="true">&gt;</span></a></li>
            <li><a href="?keyword=${keywordEncoded }&postman=${postman }&domain=${DomainEncoded }&type=${TypeEncoded }&curPage=${page.maxPage}&pageSize=${page.pageSize}"><span aria-hidden="true"> &raquo; </span></a></li>
		    </c:when>
		    <c:otherwise>
		    <li class="disabled"><a href="#" onclick="return false;"><span aria-hidden="true">&raquo;</span></a></li>
		    </c:otherwise>
		    </c:choose>    
         </ul>
      </nav>
      </div>
      
      
      </c:if>

	  
      <c:if test="${i eq 0 }">
        <div class="alert alert-warning" role="alert">
           	不好意思，没有搜索结果！&nbsp;&nbsp;&nbsp;&nbsp;
            <a  href="<%=request.getContextPath() %>/Posting/AddPosting?domain=${su:encodeUriComponent(param.domain)}" role="button">立刻前往发帖&raquo;</a>
        
        </div>
      </c:if>
      
      </c:if>
      
      </div>
      <div class="col-sm-2"></div><!--右侧不用-->
    </div>
 
    <jsp:include page="../Common/Footer.jsp"></jsp:include>

</div>

 <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
    <script src="<%=request.getContextPath()%>/static/js/jquery.min.js"></script>
    <!-- Include all compiled plugins (below), or include individual files as needed -->
    <script src="<%=request.getContextPath()%>/static/js/bootstrap.min.js"></script>

</body>
</html>